<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
<style>
    .layui-table-tool-temp {
        padding: 0 !important;
    }
</style>
<body>
    <div style="margin-left: 15px;margin-top: 15px">
        <div class="layui-input-inline">
            <label >姓名:</label>
        </div>
        <div class="layui-input-inline">
            <input class="layui-input" id="nickname" placeholder="姓名" autocomplete="off" />
        </div>
        <div class="layui-input-inline">
            <label >电话:</label>
        </div>
        <div class="layui-input-inline">
            <input class="layui-input" id="phone" placeholder="电话" autocomplete="off" />
        </div>
        <button class="layui-btn layui-btn-normal" id="search" data-type="reload">搜索</button>
    </div>
	<div class="layui-fluid">
		<table id="order_takecaruser-table" lay-filter="order_takecaruser-table"></table>
	</div>
	<!-- 工具栏 -->
	<script type="text/html" id="toolbarOrderTakecaruser">
        <div class="layui-btn-container" style="display: flex;justify-content: flex-end;">
			<button shiro:hasPermission="order:takecaruser:add" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-circle" ></i>添加</button>
        </div>
    </script>
	<!-- 操作列 -->
	<script type="text/html" id="order_takecaruser-state">
     <div class="layui-btn-group">
        <button shiro:hasPermission="order:takecaruser:edit" class="layui-btn layui-btn-sm" lay-event="edit">编辑</button>
        <button shiro:hasPermission="order:takecaruser:remove" class="layui-btn layui-btn-sm" lay-event="del">删除</button>
    </div>
    </script>
    <script th:replace="/common/template :: script"></script>
	<script>
        var active;
        layui.use([ 'layer' , 'table' ], function() {
			var $ = layui.jquery;
			var table = layui.table;
			// 渲染表格
			var renderTable = function() {
				layer.load(2);
				table.render({
					elem : '#order_takecaruser-table',
					url : '/yearaudit/order/takecaruserList',
					toolbar : '#toolbarOrderTakecaruser',
					page : true,
                    defaultToolbar: [],
					id : 'orderTakecaruserReload',
					parseData:chaoLayuiTable.parseData,
					request:chaoLayuiTable.request,
					response:chaoLayuiTable.response,
					//limit : 1,
					cols : [ [
 					{
						align : 'center',
					    field : 'nickname',
						title : '姓名',
					 
					}, 
 					{
						align : 'center',
					    field : 'phone',
						title : '电话',
					 
					},
 					{
						title : '操作',
						toolbar : '#order_takecaruser-state',
						align : 'center'
					} ] ],
					done : function() {
						layer.closeAll('loading');
					}
				});

			};
			renderTable();
			// 搜索 
			active = {
				reload : function() {
					//执行重载
					table.reload('orderTakecaruserReload', {
						page : {
							curr : 1
						//重新从第 1 页开始
						},
						where : {
                            nickname: $("#nickname").val(),
                            phone: $("#phone").val()
						}
					});
				}
			};

			$('#search').on('click', function() {
				var type = $(this).data('type');
				active[type] ? active[type].call(this) : '';
			});

			//头工具栏事件
			table.on('toolbar(order_takecaruser-table)', function(obj) {
				var checkStatus = table.checkStatus(obj.config.id);
				switch (obj.event) {
				case 'add'://增加
					openAdd();
					break;
				}
			});

			//监听工具条
			table.on('tool(order_takecaruser-table)', function(obj) {
				var data = obj.data;
				var layEvent = obj.event;
				if (layEvent === 'del') {//删除
					remove(data.id);
				} else if (layEvent === 'edit') {//修改
					edit(data.id);
				}
			});

			function remove(id) {
				parent.layer.confirm('确定要删除选中的记录？', {
					btn : [ '确定', '取消' ]
				}, function() {
					//删除
					CoreUtil.ajaxPostLoad('/order/takecaruser/remove', {
						id : id
					},true,active);
					return false;
				})
			}

			function edit(id) {
				layer.open({
					type : 2,
					title : '修改',
					maxmin : true,
					shadeClose : false, // 点击遮罩关闭层
                    area : [ '20%', '40%' ],
					content : '/order/takecaruser/edit/' + id // iframe的url
				});
			}

			function openAdd() {
				layer.open({
					type : 2,
					title : '增加',
					maxmin : true,
					shadeClose : false, // 点击遮罩关闭层
					area : [ '20%', '40%' ],
					content : '/order/takecaruser/add' // iframe的url
				});
			}
		});
	</script>
</body>
</html>